﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MapletRemoteControl/Map24MapletRemoteControl.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// Array of the locations to add

// first location
$locIdx=0;
$locations[$locIdx]['Longitude']='417.54556';
$locations[$locIdx]['Latitude']='3056.8179';

// second location
$locIdx++;
$locations[$locIdx]['Longitude']='598.3';
$locations[$locIdx]['Latitude']='3213.0068';

// third location
$locIdx++;
$locations[$locIdx]['Longitude']='514.048';
$locations[$locIdx]['Latitude']='3007.8325';

// 4 th location
$locIdx++;
$locations[$locIdx]['Longitude']='514.048';
$locations[$locIdx]['Latitude']='3007.8325';

// 5 th location
$locIdx++;
$locations[$locIdx]['Longitude']='799.04816';
$locations[$locIdx]['Latitude']='3150.8012';

// zoomlevel
$mapViewClippingWidth = 2000;

//Flightproperties

//Name of the Groupe, which should be visit
$proIdx=0;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "Map24RouteObjectID";
$property[$proIdx]->Value 	= "FLIGHTLOCS";

//FlightSpeed
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "FlightSpeed";
$property[$proIdx]->Value	= 1500;

//Zoom
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "FlightZoom";
$property[$proIdx]->Value	= 10000;

//LandingSpeed
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "FlightLandingSpeed";
$property[$proIdx]->Value	= 500;

//LandingLengthPercentage
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "FlightLandingLengthPercentage";
$property[$proIdx]->Value	= 10;

//To reverse the flight
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "FlightReverse";
$property[$proIdx]->Value	= false;

//To start the flight automatically
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "Control";
$property[$proIdx]->Value 	= "Start";


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// Array of the Locationnames
$locs=array();
// needed, because we want to start at index NULL
$cmdIdx=-1;

// here are all commands defined and are put together in one ArrayOfCommands
for($locIdx=0;$locIdx < count($locations);$locIdx++) {
	// count the command index
	$cmdIdx++;
	// define the location name
	$locname="LOC".$locIdx;
	// Add Locationname to Array
	$locs[]=$locname;
	// Build Command to add Locaton on the Map
	$commands[$cmdIdx] = new XMLCommandWrapper();
	$commands[$cmdIdx]->DeclareMap24Location = new DeclareMap24Location();
	$commands[$cmdIdx]->DeclareMap24Location->MapObjectID = $locname;
	$commands[$cmdIdx]->DeclareMap24Location->Coordinate = new Coordinate();
	$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Longitude = $locations[$locIdx]['Longitude'];
	$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Latitude = $locations[$locIdx]['Latitude'];
	$commands[$cmdIdx]->DeclareMap24Location->SymbolID = "10".$locIdx;
}

// this will add the objects to a Grupp
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMapObjectGroup = new DeclareMapObjectGroup();
$commands[$cmdIdx]->DeclareMapObjectGroup->MapObjectGroupID = "FLIGHTLOCS";
$commands[$cmdIdx]->DeclareMapObjectGroup->MapObjectIDs = $locs;


// this object will enable the new location on the map
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlMapObject = new ControlMapObject();
$commands[$cmdIdx]->ControlMapObject->Control = "ENABLE";
$commands[$cmdIdx]->ControlMapObject->MapObjectIDs = array('FLIGHTLOCS');

// Slide out the equired components for the heli flight
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlComponent = new ControlComponent();
$commands[$cmdIdx]->ControlComponent->Component= "SHOWM3D";
$commands[$cmdIdx]->ControlComponent->Control= "SHOW";


// Enable the required components for the heli flight
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlComponent = new ControlComponent();
$commands[$cmdIdx]->ControlComponent->Component= "SHOWM3DROUTE";
$commands[$cmdIdx]->ControlComponent->Control= "SHOW";


//  Pass the flight locations to the route component and set some additional properties for the flight
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlComponent = new ControlComponent();
$commands[$cmdIdx]->ControlComponent->Component= "M3DROUTE";
$commands[$cmdIdx]->ControlComponent->Control= "SHOW";
$commands[$cmdIdx]->ControlComponent->Properties=$property;



// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new MapletRemoteControlRequest();
$request->Map24MRC = new Map24MRC();
$request->Map24MRC->Commands = $commands;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$mrc = new Map24MapletRemoteControl($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mrc->mapletRemoteControl($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "This command generates no output";
$counter = 0;


?>